import { Column, Entity, ManyToOne } from 'typeorm'
import { DiscordID } from '@boticord/common'
import { ChatMessageAuthor } from '@boticord/consts'
import { User } from '@boticord/users-client'

@Entity()
export class ChatMessage extends DiscordID {
  @Column({ type: 'enum', enum: ChatMessageAuthor })
  declare from: ChatMessageAuthor

  @ManyToOne(() => User, u => u.messages)
  declare author: User

  @Column()
  declare content: string

  @Column('timestamp with time zone', { nullable: false, default: () => 'CURRENT_TIMESTAMP' })
  declare at: Date

  @Column()
  declare bot: string
}
